year, month, day, k = map(int, input().split())
day_no_leapyear = [0,31,28,31,30,31,30,31,31,30,31,30,31]
day_in_leapyear = [0,31,29,31,30,31,30,31,31,30,31,30,31]
for i in range(1, k + 1):
    if year % 100 != 0 and year % 4 == 0 or year % 400 == 0:
        day_in_year = day_in_leapyear
    else:
        day_in_year = day_no_leapyear
    day += 1
    if day == day_in_year[month] + 1:
        day = 1
        month += 1
    if month == 13:
        month = 1
        year += 1
print("{:d}-{:0>2d}-{:0>2d}".format(year, month, day))